package top.mable.payment.config;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * 初始化rabbitmq  死信 的exchange、queue
 * 配置不能跟注解一起使用
 */
//@Configuration
public class DeadRabbitMqConfig {

    /**
     * 声明注册direct模式的交换机
     * @return
     */
    @Bean
    public DirectExchange deadDirectExchange(){
        return new DirectExchange("dead_direct_exchange",true,false);
    }


    @Bean
    public Queue deadDirectQueue(){

        return new Queue("dead.direct.queue",true,false,false);
    }

    /**
     * 绑定
     * @return
     */
    @Bean
    public Binding deaddirectBinding(){
        return BindingBuilder.bind(deadDirectQueue()).to(deadDirectExchange()).with("dead.key");
    }



}
